package com.trade.wzj.common.you;



import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.trade.wzj.model.xiang.ClientInfo;
import com.trade.wzj.model.xiang.ClientQuotaDetails;
import com.trade.wzj.model.xiang.SupplierInfo;
import com.trade.wzj.service.you.SupplierService;



@Controller
@RequestMapping("/test")
public class ControllerOne {
	@Resource(name="standardService")
	private  SupplierService sup;

	public SupplierService getSup() {
		return sup;
	}

	public void setSup(SupplierService sup) {
		this.sup = sup;
	}
	
	@RequestMapping("/supProInfo")
	@ResponseBody
	public SupplierInfo supplierInfo(Integer id,Model model){
		SupplierInfo sinfo=sup.supProSel(id);
		model.addAttribute("info", sinfo);
		return sinfo; 
	}
	
	//修改供应商报价信息
	@RequestMapping("/updateSupplierPrice")
	@ResponseBody
	public boolean updateSupplierPrice(SupplierInfo supplier) {
		boolean bol=false;
		try {
			sup.updateSupplierPrice(supplier);
			bol=true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return bol;
	}
	
	
	/**
	 * 根据产品信息表的id查询客户报价详情表
	 */
	@RequestMapping("/selectClientQuotaDetails")
	@ResponseBody
	public PageInfo<ClientQuotaDetails> selectClientQuotaDetails(Integer id,Integer currentPages){
		//起始页
				Integer currentPage=1;
				//每页显示的行数
				Integer rowPerPage=5;
				PageInfo<ClientQuotaDetails> pageInfo=null;
				List<ClientQuotaDetails> list=null;
				try {
					if(null!=currentPages) {
						// 页码不为空时，将当前页信息赋值
						currentPage=currentPages;
					}
					PageHelper.startPage(currentPage, rowPerPage);
					list=sup.selectClientQuotaDetails(id);
					
					pageInfo=new PageInfo<ClientQuotaDetails>(list);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return pageInfo;
	}

	
	
}
